package com.hui.blog_server.utils;

import java.nio.charset.StandardCharsets;
import java.util.Base64;

/**
 * @author 彩色的小灰
 */
public class EncryptUtils {

    static final Base64.Decoder DECODER = Base64.getDecoder();
    static final Base64.Encoder ENCODER = Base64.getEncoder();

    //  加密
    public static String encrypt(String plainText) {
        final byte[] textByte = plainText.getBytes(StandardCharsets.UTF_8);
        return ENCODER.encodeToString(textByte);
    }

    //  解密
    public static String decrypt(String cipherText) {
        return new String(DECODER.decode(cipherText), StandardCharsets.UTF_8);
    }
}